<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>读者类型列表</title>
    <link href="../css/table.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="${basePath}js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="${basePath}js/table.js"></script>
</head>
<style type="text/css">
    #header, #content {
        width: 99%;
    }

    .anniu {
        margin-left: 500px;
    }
</style>
<script type="text/javascript">
	function editType() {
		var radios = document.getElementsByName("choosen");
		var typeId = "";
		for (var i = 0; i < radios.length; i++) {
			if (radios[i].checked == true) {
				typeId = radios[i].value;
				break;
			}
		}
		if (typeId == "") {
			alert("请选择需要操作的读者类型");
		} else {
			document.getElementById("typeId").value = typeId;
			document.operationForm.action = "${basePath}readerType/getReaderType";
			document.operationForm.submit();
		}
	}

	function deleteType() {
		var radios = document.getElementsByName("choosen");
		var typeId = "";
		for (var i = 0; i < radios.length; i++) {
			if (radios[i].checked == true) {
				typeId = radios[i].value;
				break;
			}
		}
		if (typeId == "") {
			alert("请选择需要操作的读者类型");
		} else if (confirm('确认删除吗？')) {
			document.getElementById("typeId").value = typeId;
			document.operationForm.action = "${basePath}readerType/deleteReaderType";
			document.operationForm.submit();
		}
	}

	function addType() {
		window.location.href = '${basePath}readerType/toAddReaderType';
	}
</script>
<body>
<div id="content">
	<h2>读者类型列表</h2>
	<hr>
	<table>
		<thead>
			<tr>
				<th></th>
				<th>类别名称</th>
				<th>可借书数</th>
				<th>可借天数</th>
				<th>可续借天数</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="list" items="${readerTypeList}">
				<tr>
					<td><input type="radio" name="choosen" value="${list.id}"></td>
					<td>${list.name}</td>
					<td>${list.bookmax}</td>
					<td>${list.daymax}</td>
					<td>${list.continueday}</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
    <form name="operationForm" action="" method="post" class="anniu">
        <input type="hidden" id="typeId" name="typeId" value=""> <input
            type="button" onclick="javascript:addType()" value="新增"> <input
            type="button" onclick="javascript:editType()" value="修改"> <input
            type="button" onclick="javascript:deleteType()" value="删除">
    </form>
</div>
</body>
</html>
